package com.hyx.bookManager.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDate;

/**
 * @ClassName UserRedisUtil
 * @Description TODO
 * @Author 黄乙轩
 * @Date 2021/5/8 10:54
 * @Version 1.0
 **/

@Component
public class UserRedisUtil {
    @Autowired
    private RedisUtil redisUtil;

    public boolean setOnline(long userId,boolean b){
        return redisUtil.setBit("online",userId,b);
    }

    public boolean setDateOnline(long userId){
        LocalDate date = LocalDate.now();
        return redisUtil.setBit(date.toString(),userId,true);
    }

    public long getDateOnline(LocalDate date){
        return redisUtil.bitCount(date.toString());
    }

    public String setUserToken(Long userId){
        return null;
    }

}
